package cn.onein.edu.web.dao;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.orm.ibatis.SqlMapClientTemplate;
import org.springframework.stereotype.Service;

import cn.onein.edu.biz.bean.SharedActions;
import cn.onein.edu.biz.bean.User;
import cn.onein.edu.biz.bean.UserDailyAction;

@Service
public class UserCenterDao {

	@Autowired
	private SqlMapClientTemplate sqlMapClientTemplate;
	
	public User getUserById(Long id){
		return (User)sqlMapClientTemplate.queryForObject("getUserById",id);
	}
	
	
	@SuppressWarnings("unchecked")
	public List<UserDailyAction> getDailyAction(Map<String,Object> map){
		return (List<UserDailyAction>)sqlMapClientTemplate.queryForList("getDailyAction",map);
	}
	
	@SuppressWarnings("unchecked")
	public List<UserDailyAction> getDailyActionByDesc(Map<String,Object> map){
		return (List<UserDailyAction>)sqlMapClientTemplate.queryForList("getDailyActionByDesc",map);
	}
	
	public void insertBabyDaily(Map<String,Object> map){
		sqlMapClientTemplate.update("updateBabyDailyOfUserActions",map);
	}
	
	public void insertShareAction(Map<String,Object> map){
		sqlMapClientTemplate.insert("insertShareAction",map);
	}
	
	public SharedActions getShareAction(Map<String,Object> map){
		return (SharedActions)sqlMapClientTemplate.queryForObject("getShareAction",map);
	}
	
	public void updateShareAction(Map<String,Object> map){
		sqlMapClientTemplate.update("updateShareAction", map);
	}
	
	public UserDailyAction getDailyActionByUserIdAndDate(Map<String,Object> map){
		return (UserDailyAction)sqlMapClientTemplate.queryForObject("getDailyActionByUserIdAndDate", map);
	}
	
	public SharedActions getShareActionByUUID(String uuid){
		return (SharedActions)sqlMapClientTemplate.queryForObject("getShareByUUID",uuid);
	}
	
	public void updateUserActionActive(Map<String,Object> map){
		sqlMapClientTemplate.update("updateUserActionActive", map);
	}
}
